#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File     : __init__.py
@Project  : pipecoco
@Date     : 2021/8/13
@Author   : Zhang Jinyang
@Contact  : zhang-jy@sjtu.edu.cn
'''

import time
import logging
import os


logger = logging.getLogger('client')
logger.setLevel(logging.INFO)

rf_handler = logging.StreamHandler()  # 默认是sys.stderr
rf_handler.setFormatter(logging.Formatter("%(asctime)s - %(message)s"))
rf_handler.setLevel(logging.INFO)

current_time = time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime())
dir = './log/' + current_time
if not os.path.exists(dir):
    os.makedirs(dir)

f_handler = logging.FileHandler(dir+'/client.log')
f_handler.setFormatter(logging.Formatter("%(asctime)s - %(message)s"))
f_handler.setLevel(logging.INFO)

logger.addHandler(rf_handler)
logger.addHandler(f_handler)


logger = logging.getLogger('server')
logger.setLevel(logging.INFO)

f_handler = logging.FileHandler(dir+'/server.log')
f_handler.setFormatter(logging.Formatter("%(asctime)s - %(message)s"))
f_handler.setLevel(logging.INFO)

logger.addHandler(rf_handler)
logger.addHandler(f_handler)



logger = logging.getLogger('best_config')
logger.setLevel(logging.INFO)

f_handler = logging.FileHandler(dir + '/param.log')
f_handler.setFormatter(logging.Formatter("%(asctime)s - %(message)s"))
f_handler.setLevel(logging.INFO)

logger.addHandler(rf_handler)
logger.addHandler(f_handler)

logger = logging.getLogger('net')
f_handler = logging.FileHandler(dir+'/net.log')
f_handler.setFormatter(logging.Formatter("%(asctime)s - %(message)s"))
f_handler.setLevel(logging.INFO)

logger.addHandler(rf_handler)
logger.addHandler(f_handler)